package com.ruoyi.project.system.mcstask.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.mcstask.domain.McsTask;
import com.ruoyi.project.system.mcstask.service.IMcsTaskService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * MCS搬运任务Controller
 * 
 * @author thomas
 * @date 2019-11-04
 */
@Controller
@RequestMapping("/system/mcstask")
public class McsTaskController extends BaseController
{
    private String prefix = "system/mcstask";

    @Autowired
    private IMcsTaskService mcsTaskService;

    @RequiresPermissions("system:mcstask:view")
    @GetMapping()
    public String mcstask()
    {
        return prefix + "/mcstask";
    }

    /**
     * 查询MCS搬运任务列表
     */
    @RequiresPermissions("system:mcstask:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(McsTask mcsTask)
    {
        startPage();
        List<McsTask> list = mcsTaskService.selectMcsTaskList(mcsTask);
        return getDataTable(list);
    }

    /**
     * 导出MCS搬运任务列表
     */
    @RequiresPermissions("system:mcstask:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(McsTask mcsTask)
    {
        List<McsTask> list = mcsTaskService.selectMcsTaskList(mcsTask);
        ExcelUtil<McsTask> util = new ExcelUtil<McsTask>(McsTask.class);
        return util.exportExcel(list, "mcstask");
    }

    /**
     * 新增MCS搬运任务
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存MCS搬运任务
     */
    @RequiresPermissions("system:mcstask:add")
    @Log(title = "MCS搬运任务", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(McsTask mcsTask)
    {
        return toAjax(mcsTaskService.insertMcsTask(mcsTask));
    }

    /**
     * 修改MCS搬运任务
     */
    @GetMapping("/edit/{taskNo}")
    public String edit(@PathVariable("taskNo") String taskNo, ModelMap mmap)
    {
        McsTask mcsTask = mcsTaskService.selectMcsTaskById(taskNo);
        mmap.put("mcsTask", mcsTask);
        return prefix + "/edit";
    }

    /**
     * 修改保存MCS搬运任务
     */
    @RequiresPermissions("system:mcstask:edit")
    @Log(title = "MCS搬运任务", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(McsTask mcsTask)
    {
        return toAjax(mcsTaskService.updateMcsTask(mcsTask));
    }

    /**
     * 删除MCS搬运任务
     */
    @RequiresPermissions("system:mcstask:remove")
    @Log(title = "MCS搬运任务", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(mcsTaskService.deleteMcsTaskByIds(ids));
    }
}
